<?php
$pacth="C:/xampp/htdocs/05_NIV/";
include ($pacth.'PHPMailer/class.phpmailer.php');
include ($pacth.'PHPMailer/class.smtp.php');
function sendemail($toemail,$text,$body){
	$guser='system@neowiz.vn';
	$gpass="neowiz123!@#";
	$gname='Neowiz System';
	if(smtpmailer($toemail,$text,$body,$guser,$gpass,$gname)){
		return true;
	}return false;
}
function  smtpmailer($SenderEmail,$text,$body,$guser,$gpass,$gname) {
        ////mail nguoi nhan , tai khoan (ten nguoi nhan) , pass muon gui , tieu de mail , noi dung mail , account gmail, pass gmail , ten nguoi gui
        $mail = new PHPMailer();
        $mail->IsSMTP(); // set mailer to use SMTP
        $mail->Host = "smtp.gmail.com"; // specify main and backup server
        $mail->Port = 465; // set the port to use
        $mail->SMTPAuth = true; // turn on SMTP authentication
        $mail->SMTPSecure = 'ssl';
        $mail->Mailer = "smtp";
        $mail->CharSet="utf-8";
        $mail->Username = $guser; // your SMTP username or your gmail username
        $mail->Password = $gpass; // your SMTP password or your gmail password
        $from = $guser; // Reply to this email
        $mail->AddReplyTo($guser, "Reply");
        $mail->From = $from;
        $mail->FromName = $gname; // Name to indicate where the email came from when the recepient received
        foreach ($SenderEmail as $se){
            $mail->AddAddress($se["email"],$se["name"]);
        }

        $mail->AddReplyTo($from,$gname);
        $mail->WordWrap = 50; // set word wrap
        $mail->IsHTML(true); // send as HTML
        $mail->Subject = $text;
        $mail->Body = $body; //HTML Body
        $mail->AltBody = "Contac US"; //Text Body
        $mail->SMTPDebug = false;
        if(!$mail->Send())
        {
             return false;
             
        }return true;
        
}
